/*

  Implementation of string splitter.

  @author Richard Kelley, based on code from C++ Cookbook by Stephens
  et. al.

*/

#include "splitter.h"

void split(const std::string& s, const char c,
           std::vector<std::string>& v) {

  std::string::size_type i = 0;
  std::string::size_type j = s.find(c);

  while (j != std::string::npos) {
    v.push_back(s.substr(i, j-i));
    i = j;
    j = s.find(c, j+1);
  
    
    if (j == std::string::npos)
      v.push_back(s.substr(i, s.length()));
  }
}
